package com.platform.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.platform.entity.UrlHtmlConfigEntity;
import com.platform.service.UrlHtmlConfigService;
import com.platform.utils.PageUtils;
import com.platform.utils.Query;
import com.platform.utils.R;

/**
 * h5url地址配置Controller
 *
 * @author lipengjun
 * @email 939961241@qq.com
 * @date 2019-03-10 10:36:54
 */
@RestController
@RequestMapping("urlhtmlconfig")
public class UrlHtmlConfigController {
    @Autowired
    private UrlHtmlConfigService urlHtmlConfigService;

    /**
     * 查看列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("urlhtmlconfig:list")
    public R list(@RequestParam Map<String, Object> params) {
        //查询列表数据
        Query query = new Query(params);

        List<UrlHtmlConfigEntity> urlhtmlconfigList = urlHtmlConfigService.queryList(query);
        int total = urlHtmlConfigService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(urlhtmlconfigList, total, query.getLimit(), query.getPage());

        return R.ok().put("page", pageUtil);
    }

    /**
     * 查看信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("urlhtmlconfig:info")
    public R info(@PathVariable("id") Integer id) {
        UrlHtmlConfigEntity urlhtmlconfig = urlHtmlConfigService.queryObject(id);
        return R.ok().put("urlhtmlconfig", urlhtmlconfig);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("urlhtmlconfig:save")
    public R save(@RequestBody UrlHtmlConfigEntity urlhtmlconfig) {
        urlHtmlConfigService.save(urlhtmlconfig);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("urlhtmlconfig:update")
    public R update(@RequestBody UrlHtmlConfigEntity urlhtmlconfig) {
        urlHtmlConfigService.update(urlhtmlconfig);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("urlhtmlconfig:delete")
    public R delete(@RequestBody Integer[] ids) {
        urlHtmlConfigService.deleteBatch(ids);
        return R.ok();
    }

    /**
     * 查看所有列表
     */
    @RequestMapping("/queryAll")
    public R queryAll(@RequestParam Map<String, Object> params) {
        List<UrlHtmlConfigEntity> list = urlHtmlConfigService.queryList(params);
        return R.ok().put("list", list);
    }
}
